require(["./config"],function(){
  require(["jquery","template","zoom","loadHF"],function($,template,elevateZoom){
      function Detail(){
        this.showelevateZoom();
        this.findById();
      }

      Detail.prototype = {
        constructor:Detail,
        showelevateZoom(){

          $(".show_large").elevateZoom({
	        	gallery:'detailsmall',
	        	cursor: 'pointer',
	        	galleryActiveClass: "active",
	        	imageCrossfade: true,
	        	loadingIcon: "http://www.elevateweb.co.uk/spinner.gif",
	        	scrollZoom : true

            // zoomType				: "inner",
	          //   debug : true,
	          //   cursor: "crosshair",
	          //   zoomWindowFadeIn: 500,
			      // zoomWindowFadeOut: 500

    	  		})
        },
        findById(){
          const id = (window.location.search.slice(1).split("="))[1];
          /* ajax请求find.php接口 */
        	$.ajax({
        		method: "get",
        		url: "http://localhost/etude_project/api/v1/details.php",
        		data: {id},
        		dataType: "json",
        		success: function(data) {
        			let html = "";
              let curr = data.res_body.data;
        				html += `<dl>
                          <dt>${curr.title}</dt>
                          <dd id="price">单价：￥${curr.price}</dd>
                          <dd class="add_btns">
                            <button class="add_to_cart">加入购物车</button>
                            <button class="buy_at_once">立即购买</button>
                          </dd>
                        </dl>`;
      		    $("#detail_right").html(html);
            }
          })
        }
      }

      new Detail();
  })
})
